package com.dzxcqmxm.servlet.album;

import com.dzxcqmxm.Dao.AlbumDao;
import com.dzxcqmxm.Dao.UserDao;
import com.dzxcqmxm.Dao.impl.AlbumDaoImpl;
import com.dzxcqmxm.Dao.impl.UserDaoImpl;
import com.dzxcqmxm.JB.Album;
import com.dzxcqmxm.JB.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Payboi
 * @create 2022/6/4-19:28
 * @FileName updateAlbumNameServlet
 * @Description
 */
@WebServlet("/updateAlbumNameServlet")
public class updateAlbumNameServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AlbumDao albumDao = new AlbumDaoImpl();
        Album album = new Album();


        album.setAlbumName(new String(request.getParameter("AlbumName" ).getBytes("iso-8859-1"),"UTF-8"));
        album.setAlbumBaoMi(new String(request.getParameter("AlbumBaoMi" ).getBytes("iso-8859-1"),"UTF-8"));

        try {
            /**
             * 执行了更新语句
             */
            albumDao.updateAlbumName(album);
        } catch (Exception e) {
            e.printStackTrace();
        }

        response.sendRedirect("/dzxc/YongHu/yhContent.jsp");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
